package 笔试.小米;

import java.net.ServerSocket;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/8-19:35
 * @version:1.0
 * @function:
 */
public class Main01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int row = str1.length();
        int clo = str1.length();
        int [][] dp = new int[row+1][clo+1];
        for (int i = 1; i < row+1; i++) {
            for (int j = 1; j < clo+1; j++) {
                if (str1.charAt(i-1)==str2.charAt(j-1))
                    dp[i][j] = dp[i-1][j-1]+1;
                else
                    dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }
        System.out.println(dp[row][clo]);
//        if (dp[row][clo]==0) System.out.println(-1);
//        else {
//            char[] lcs = new char[dp[row][clo]];
//        }

    }
}
